/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.easoft.code.pos.ui.controllers.impl;

import com.easoft.code.pos.data.dao.GenericDao;
import com.easoft.code.pos.data.exception.CoreDataLayerException;
import com.easoft.code.pos.data.pojos.PosCaja;
import com.easoft.code.pos.data.pojos.PosImpresora;
import com.easoft.code.pos.data.util.QueryParameter;
import com.easoft.code.pos.ui.controllers.DataEntryController;
import com.easoft.code.pos.ui.models.PojoListModel;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Eliu
 */
public class CajasControllerImpl extends DataEntryController<PosCaja> {

    public CajasControllerImpl() {

        super(Arrays.asList(new String[]{"Id",
            "Nombre", "Impresora"}),
                Arrays.asList(new String[]{"Id", "Nombre", "PosImpresora"}), PosCaja.class);
        prepareCombos();
    }

    private void prepareCombos() {
        try {
            List<PosImpresora> l = (List<PosImpresora>) GenericDao.getMe().doNamedQuery("PosImpresora.findAll", new QueryParameter[]{},
                    PosImpresora.class, false);
            PojoListModel mod = new PojoListModel(l);
            addNewModel("PosImpresora", mod);
        } catch (CoreDataLayerException ex) {
            Logger.getLogger(ProductosControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public void reload() {
        prepareCombos();
        super.reload();
    }
}
